#ifndef TC_HEAP_HH
#define TC_HEAP_HH

/** \file Heap.hh 
 * Declarations of the abstract class Heap.
 *
 * (c) Copyright 2003-2006 by Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: Heap.hh 119 2006-06-21 04:57:25Z semihc $
 *
 *
 */


#include <cstddef>
#include "Global.hh"


namespace TC {
  

  /** 
   * Interface class representing the heap concept.
   * All subclasses should have monostate characteristics.
   * In Multi-treading environments, all member functions
   * (static, non-static) serialize, that is they should have
   * class-wide lock.
   */
  class Heap
  {
  public:
    // TYPES
    enum MemType_e {
      e_Scalar = 1,
      e_Array = 2
    };

    // CREATORS
    //! Destructor
    virtual ~Heap();

    // ACCESSORS
    //! Print all accumulated statistics.
    virtual void printStats() const;

    // MODIFIERS
    //! Allocate raw memory.
    virtual void* allocate(std::size_t);
      
    //! Deallocate raw memory.
    virtual void deallocate(void*);
    
    //! The newMem is to be called by new operators.
    virtual void* newMem(std::size_t size, MemType_e mtype);

    //! The deleteMem is to be called by delete operators.
    virtual void deleteMem(void* ptr, MemType_e mtype);

    //! Reset all accumulated statistics.
    virtual void resetStats();



  }; // end class



} // end namespace



/** 
 * Overloaded versions of new and delete operators
 * operating on Heap of our choice. They should be
 * declared in global scope for strict standard
 * compliance.
 */ 

void* operator new(std::size_t size, TC::Heap&);
void* operator new[](std::size_t size, TC::Heap&);

void operator delete(void *ptr, TC::Heap&);
void operator delete[](void *ptr, TC::Heap&);



#endif /* TC_HEAP_HH */
